﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;




    public class busDiem
    {
        public List<entDiem> getDiemHocKy(string nam, string masv)
        {
            datDiem datD = new datDiem();
            string namhoc = nam.Substring(0, 4);
            string hocky = nam.Substring(4, 3);
            List<entDiem> lst = new List<entDiem>();
            lst = datD.getDiemHocKy(namhoc, hocky, masv);
            foreach (entDiem item in lst)
            {
                item.DiemH4 = float.Parse( Diem42s(item.Diem));
                item.DiemC = DiemChu2(item.Diem);
            }
            return lst;
        }
        public List<entDiem> getDiemTBTL(string masv)
        {
            datDiem datD = new datDiem();
            List<entDiem> lst = new List<entDiem>();
            return datD.getDiemTBTL(masv);
        }
        public List<entDiem> getDiemHocKy(string nam, string hk, string masv)
        {
            datDiem datD = new datDiem();
            List<entDiem> lst = new List<entDiem>();
            lst = datD.getDiemHocKy(nam, hk, masv);
            foreach (entDiem item in lst)
            {
                item.DiemH4 = float.Parse( Diem42s(item.Diem));
                item.DiemC = DiemChu2(item.Diem);
            }
            return lst;
        }
        public List<entDiem> getDiemChuongTrinhDT(string masv)
        {
            datDiem datD = new datDiem();
            List<entDiem> lst = new List<entDiem>();
            lst = datD.getDiemChuongTrinhDT(masv);
            foreach (entDiem item in lst)
            {
                item.DiemH42 = Diem42s(item.Diem);
                item.DiemC = DiemChu2(item.Diem);
            }
            return lst;
        }
        public List<entDiem> getDiemTBHocKy(string nam,  string masv)
        {
            datDiem datD = new datDiem();
            List<entDiem> lst = new List<entDiem>();
            string namhoc = nam.Substring(0, 4);
            string hocky = nam.Substring(4, 3);
            lst = datD.getDiemTBHocKy(namhoc, hocky, masv);
            return lst;
        }
        public List<entDiem> getNamHocHocKy(string masv)
        {
            datDiem datD = new datDiem();
            return datD.getNamHocHocKy(masv);
        }
        public List<entDiem> getDiemThanhPhan(string mamon, string masv)
        {
            datDiem datD = new datDiem();
            return datD.getDiemThanhPhan(mamon, masv);
        }
        string Diem42s(float Diem)
        {
            // Quy ch? m?i
            string DiemReturn = "0";
            if (Diem < 4)
            {
                if (Diem < 0)
                {
                    DiemReturn = "";
                }
                else
                {
                    DiemReturn = "0";
                }
            }
            if (Diem >= 4 && Diem < 5) DiemReturn = "1.0";
            if (Diem >= 5 && Diem < 5.5) DiemReturn = "1.5";
            if (Diem >= 5.5 && Diem < 6.5) DiemReturn = "2.0";
            if (Diem >= 6.5 && Diem < 7) DiemReturn = "2.5";
            if (Diem >= 7 && Diem < 8) DiemReturn = "3.0";
            if (Diem >= 8 && Diem < 8.5) DiemReturn = "3.5";
            if (Diem >= 8.5) DiemReturn = "4.0";
            return DiemReturn;
        }
        string DiemChu2(float Diem)
        {
            // Quy ch? m?i
            string DiemReturn = "";
            if (Diem < 4 && Diem>=0) DiemReturn = "F";
            if (Diem >= 4 && Diem < 5) DiemReturn = "D";
            if (Diem >= 5 && Diem < 5.5) DiemReturn = "D+";
            if (Diem >= 5.5 && Diem < 6.5) DiemReturn = "C";
            if (Diem >= 6.5 && Diem < 7) DiemReturn = "C+";
            if (Diem >= 7 && Diem < 8) DiemReturn = "B";
            if (Diem >= 8 && Diem < 8.5) DiemReturn = "B+";
            if (Diem >= 8.5) DiemReturn = "A";
            return DiemReturn;
        }
    }

